package com.leenmvc.core.security;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * 密码校验重写
 * 
 * @author leen_pc
 *
 */
public class CredentialMatcher extends SimpleCredentialsMatcher {
	
	@Override
	public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
		UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken)token;
		String password = new String(usernamePasswordToken.getPassword());
		String dbpassword = (String) info.getCredentials();
        return this.equals(password, dbpassword);
	}

}
